package harima.agameditor.mapeditor.control;

import harima.agameditor.common.control.AwesomeEditorEnviroment;
import harima.agameditor.common.ui.BaseEditorView;
import harima.agameditor.mapeditor.ui.MapCanvas_panel;
import harima.agameditor.mapeditor.ui.MapEditorView_panel;
import harima.agameditor.mapeditor.ui.TileBrowser_panel;
import harima.agameditor.mapeditor.ui.TilePalete_panel;
import harima.agameditor.mapeditor.ui.complement.MapEditorView;
import harima.agameditor.resources.PanelIds;
import harima.agamengine.mapmodel.MapModel;

public class MapEditorController {
	
	MapEditorServices services;
	MapEditorState state;
	MapEditorView view;
	
	public MapEditorController() {
		services = new MapEditorServices();
		state = new MapEditorState();
	}

	public void setWorkingmap(MapModel map) {
		state.setMap(map);
		view.enableMapSave(true);
		
		TileBrowser_panel browseTiles = (TileBrowser_panel)view.getPanel(PanelIds.TILE_BROWSER_PANEL);
		if(browseTiles != null){browseTiles.reloadList();}
		
		TilePalete_panel tilePalete = (TilePalete_panel)view.getPanel(PanelIds.TILE_PALETE_PANEL);
		if(tilePalete != null){tilePalete.reloadPalete();}
	
		MapCanvas_panel mapCanvas = (MapCanvas_panel)view.getPanel(PanelIds.MAP_CANVAS_PANEL);
		if(mapCanvas != null){mapCanvas.repaint();}
	}
	
	
	
	public MapEditorState getEditorState() {return state;}
	public MapEditorServices getServices() {return services;}
	public BaseEditorView getView() {return view;}
	public void setView(MapEditorView _view) {	view = _view;}

}
